package com.bwie.config;

import com.aliyun.oss.OSSClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration
@PropertySource("classpath:application.yml")
@ConfigurationProperties(prefix = "oss")
public class TwoOssConfig {

    //oss:
    //  accesskeyId: LTAI5tSF6zfN2g7aDSNcf2Bs # 应用的appid
    //  accesskeySecret: SHTL00jKWD4QQLgut2j0ynw7yNIZXm #签名
    //  endpoint: oss-cn-beijing.aliyuncs.com # 存储空间(地域节点)
    //  urlPrefix:  http://oss-cn-beijing.aliyuncs.com # 访问地址
    //  bucketName: wangruij # 存储空间名称
    //  fileHost: images # 文件夹的名称

    private String accesskeyId;
    private String accesskeySecret;
    private String endpoint;
    private String urlPrefix;
    private String bucketName;
    private String fileHost;

    public String getAccesskeyId() {
        return accesskeyId;
    }

    public void setAccesskeyId(String accesskeyId) {
        this.accesskeyId = accesskeyId;
    }

    public String getAccesskeySecret() {
        return accesskeySecret;
    }

    public void setAccesskeySecret(String accesskeySecret) {
        this.accesskeySecret = accesskeySecret;
    }

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getUrlPrefix() {
        return urlPrefix;
    }

    public void setUrlPrefix(String urlPrefix) {
        this.urlPrefix = urlPrefix;
    }

    public String getBucketName() {
        return bucketName;
    }

    public void setBucketName(String bucketName) {
        this.bucketName = bucketName;
    }

    public String getFileHost() {
        return fileHost;
    }

    public void setFileHost(String fileHost) {
        this.fileHost = fileHost;
    }

    @Bean
    public OSSClient ossClient(){
        return new OSSClient(endpoint,accesskeyId,accesskeySecret);
    }
}
